﻿using System.Windows.Input;
using VisualWip.Core;
using VisualWip.Core.Interfaces;

namespace VisualWip.PresentationModel.ViewModels
{
    public class RecentSettingsViewModel
    {
        private readonly Application _application;
        private readonly IPersistanceProvider _persistanceProvider;
        private readonly ISettingsPath _settingsPath;
        private ICommand _openRecentCommand;

        public RecentSettingsViewModel(Application application, IPersistanceProvider persistanceProvider,
                                       ISettingsPath settingsPath)
        {
            _application = application;
            _persistanceProvider = persistanceProvider;
            _settingsPath = settingsPath;
        }

        public ICommand OpenRecentCommand
        {
            get
            {
                if (_openRecentCommand == null)
                {
                    _openRecentCommand =
                        new RelayCommand(param => _application.Load(_persistanceProvider.Load(_settingsPath)));
                }
                return _openRecentCommand;
            }
        }

        public string Label
        {
            get { return _settingsPath.Path; }
        }
    }
}